package classes;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.List;

public class LifebookImageSearchParameters {

    private String searchUsername;
    private String searchTitle;
    private String searchTag;
    private String searchCategory;
    private String searchPinInfo;
    private String leader;
    private String follower;
    private String searchString;
    private int exactUser = 0;
    private boolean sortByDate = false;

    public LifebookImageSearchParameters(String searchUsername, String searchTitle, String searchTag, String searchCategory, String searchPinInfo, String leader, String follower) {
        this.searchUsername = searchUsername.trim();
        this.searchTitle = searchTitle.trim();
        this.searchTag = searchTag.trim();
        this.searchCategory = searchCategory.trim();
        this.searchPinInfo = searchPinInfo.trim();
        this.leader = leader.trim();
        this.follower = follower.trim();
        this.setSearchString(searchUsername, searchTitle, searchTag, searchCategory, searchPinInfo, leader, follower);
    }

    public LifebookImageSearchParameters(String searchUsername, String searchTitle, String searchTag, String searchCategory, String searchPinInfo) {
        this(searchUsername, searchTitle, searchTag, searchCategory, searchPinInfo, "", "");
    }

    public LifebookImageSearchParameters(String username, int exactUser) {
        this.searchUsername = username;
        this.searchTitle = "";
        this.searchTag = "";
        this.searchCategory = "";
        this.searchPinInfo = "";
        this.leader = "";
        this.follower = "";
        this.exactUser = exactUser;
        this.setSearchString(searchUsername, searchTitle, searchTag, searchCategory, searchPinInfo, leader, follower);
    }

    public LifebookImageSearchParameters(String follower, boolean sortByDate) {
        this.searchUsername = "";
        this.searchTitle = "";
        this.searchTag = "";
        this.searchCategory = "";
        this.searchPinInfo = "";
        this.leader = "";
        this.follower = follower;
        this.exactUser = 0;
        this.sortByDate = sortByDate;
        this.setSearchString(searchUsername, searchTitle, searchTag, searchCategory, searchPinInfo, leader, follower);
    }

    public LifebookImageSearchParameters(String keyword) {
        this.searchUsername = keyword;
        this.searchTitle = keyword;
        this.searchTag = keyword;
        this.searchCategory = keyword;
        this.searchPinInfo = keyword;
        this.leader = "";
        this.follower = "";
        this.setSearchString(keyword);
    }

    public LifebookImageSearchParameters() {
        this("");
    }

    public LifebookImageSearchParameters(boolean sortByDate) {
        this("");
        this.sortByDate = sortByDate;
        this.setSearchString("");
    }

    private void setSearchString(String keyword) {
        setSearchString(keyword, "", "");
    }

    private void setSearchString(String keyword, String leader, String follower) {
        String unionSearchString = " ";
        String leaderString = " ";
        String followerString = " ";
        String endString = " ";

        unionSearchString = "select * from(\n"
                + "    select \n"
                + "    *\n"
                + "from\n"
                + "    (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            count(`likedImages`.`imageID`) as `likes`\n"
                + "    from\n"
                + "        `image`\n"
                + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                + "    where `ownerUsername` like '%" + keyword + "%'\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc) as `image`\n"
                + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                + "    group by `imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `usernameSearch`\n"
                + "    \n"
                + "    union\n"
                + "    \n"
                + "    select \n"
                + "    *\n"
                + "from\n"
                + "    (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            count(`likedImages`.`imageID`) as `likes`\n"
                + "    from\n"
                + "        `image`\n"
                + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                + "    where imageTitle like '%" + keyword + "%'\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc) as `image`\n"
                + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                + "    group by `imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `titleSearch`\n"
                + "    \n"
                + "    union\n"
                + "    \n"
                + "    select \n"
                + "    *\n"
                + "from\n"
                + "    (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            count(`likedImages`.`imageID`) as `likes`\n"
                + "    from\n"
                + "        `image`\n"
                + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc) as `image`\n"
                + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                + "    left join `pintag` on `pintag`.`pinID` = `imagepins`.`pinID`\n"
                + "    where `pintag`.`pinTag` like '%" + keyword + "%'\n"
                + "    group by `image`.`imageID`, `pintag`.`pinID`, `pintag`.`pinTag`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                + "    group by `imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `tagSearch`\n"
                + "    \n"
                + "    union\n"
                + "    \n"
                + "    select \n"
                + "    *\n"
                + "from\n"
                + "    (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            count(`likedImages`.`imageID`) as `likes`\n"
                + "    from\n"
                + "        `image`\n"
                + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc) as `image`\n"
                + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                + "    where pinInfo like '%" + keyword + "%'\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                + "    group by `imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `pinInfoSearch`\n"
                + "    \n"
                + "    union\n"
                + "    \n"
                + "    select \n"
                + "    *\n"
                + "from\n"
                + "    (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            count(`likedImages`.`imageID`) as `likes`\n"
                + "    from\n"
                + "        `image`\n"
                + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc) as `image`\n"
                + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                + "    where `pinCategory` like '%" + keyword + "%'\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                + "    group by `imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `categorySearch`\n"
                + ") as `unionSearch`";

        if (leader.trim().length() != 0) {
            leaderString = "inner join\n"
                    + "\n"
                    + "(select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`follower`\n"
                    + "    where `followers`.`username` = '" + leader.trim() + "'\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `leaderSearch`\n"
                    + "on leaderSearch.imageID = unionSearch.imageID\n";
        }
        if (follower.trim().length() != 0) {
            followerString = "inner join \n"
                    + "    \n"
                    + "(select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    where `followers`.`follower` = '" + follower.trim() + "'\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `followerSearch`"
                    + "    on followerSearch.imageID = unionSearch.imageID\n";
        }

        endString = "where unionSearch.isEnabled = 1\n"
                + "group by unionSearch.imageID\n"
                + (this.sortByDate ? "order by unionSearch.`Date` desc" : "order by unionSearch.likes desc, unionSearch.pinlikes desc");

        this.searchString = unionSearchString + leaderString + followerString + endString;
    }

    private void setSearchString(String searchUsername, String searchTitle, String searchTag, String searchCategory, String searchPinInfo, String leader, String follower) {
        String masterSearch = "select \n"
                + "            `masterSearch`.`imageID`,\n"
                + "            `masterSearch`.`ownerUsername`,\n"
                + "            `masterSearch`.`imageFile`,\n"
                + "            `masterSearch`.`imageTitle`,\n"
                + "            `masterSearch`.`imageCaption`,\n"
                + "            `masterSearch`.`isEnabled`,\n"
                + "            `masterSearch`.`viewCount`,\n"
                + "            `masterSearch`.`Date`,\n"
                + "            `masterSearch`.`width`,\n"
                + "            `masterSearch`.`height`,\n"
                + "            `masterSearch`.`likes`,\n"
                + "            `masterSearch`.`pinlikes`\n"
                + "from\n"
                + "    (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            count(`likedImages`.`imageID`) as `likes`\n"
                + "    from\n"
                + "        `image`\n"
                + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc) as `image`\n"
                + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                + "    group by `imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `masterSearch` ";
        String endSearch = " where masterSearch.isEnabled = 1\n" + (this.sortByDate ? "order by `Date` desc" : "");

        String joinUsername = " ";
        String joinTitle = " ";
        String joinTag = " ";
        String joinCategory = " ";
        String joinPinInfo = " ";
        String joinLeader = " ";
        String joinFollower = " ";

        String userString = exactUser == 0 ? "like '%" + searchUsername.trim() + "%' \n"
                : "= '" + searchUsername.trim() + "' \n";

        if (searchUsername.trim().length() != 0) {
            joinUsername = "    inner join \n"
                    + "\n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    where `ownerUsername` " + userString
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `usernameSearch`\n"
                    + "    \n"
                    + "    on usernameSearch.imageID = masterSearch.imageID ";
        }

        if (searchTitle.trim().length() != 0) {
            joinTitle = "    inner join\n"
                    + "    \n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    where imageTitle like '%" + searchTitle.trim() + "%'\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `titleSearch`\n"
                    + "    \n"
                    + "    on titleSearch.imageID = masterSearch.imageID";
        }
        if (searchTag.trim().length() != 0) {
            joinTag = "    inner join\n"
                    + "    \n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    left join `pintag` on `pintag`.`pinID` = `imagepins`.`pinID`\n"
                    + "    where `pintag`.`pinTag` like '%" + searchTag.trim() + "%'\n"
                    + "    group by `image`.`imageID`, `pintag`.`pinID`, `pintag`.`pinTag`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `tagSearch`\n"
                    + "    \n"
                    + "    on tagSearch.imageID = masterSearch.imageID";
        }
        if (searchCategory.trim().length() != 0) {
            joinCategory = "    inner join\n"
                    + "    \n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    where `pinCategory` = '" + searchCategory.trim() + "'\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `categorySearch`\n"
                    + "    \n"
                    + "    on categorySearch.imageID = masterSearch.imageID ";
        }
        if (searchPinInfo.trim().length() != 0) {
            joinPinInfo = "    inner join\n"
                    + "    \n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    where pinInfo like '%" + searchPinInfo.trim() + "%'\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `pinInfoSearch`\n"
                    + "    \n"
                    + "    on pinInfoSearch.imageID = masterSearch.imageID ";
        }
        if (leader.trim().length() != 0) {
            joinLeader = "    inner join\n"
                    + "    \n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`follower`\n"
                    + "    where `followers`.`username` = '" + leader.trim() + "'\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `leaderSearch`\n"
                    + "    on leaderSearch.imageID = masterSearch.imageID ";
        }
        if (follower.trim().length() != 0) {
            joinFollower = "    inner join \n"
                    + "\n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    where `followers`.`follower` = '" + follower.trim() + "'\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc\n"
                    + "    ) as `followerSearch`\n"
                    + "\n"
                    + "    on followerSearch.imageID = masterSearch.imageID \n";
        }

        this.searchString = masterSearch + joinUsername + joinTitle + joinTag + joinCategory + joinPinInfo
                + joinLeader + joinFollower + endSearch;
    }

    //Search related Pins
    public LifebookImageSearchParameters(String category, List<String> tags) {
        String categorySearch = "    select \n"
                + "    *\n"
                + "from\n"
                + "    (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            `likes`,\n"
                + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                + "    from\n"
                + "        (select \n"
                + "        `image`.`imageID`,\n"
                + "            `ownerUsername`,\n"
                + "            `imageFile`,\n"
                + "            `imageTitle`,\n"
                + "            `imageCaption`,\n"
                + "            `isEnabled`,\n"
                + "            `viewCount`,\n"
                + "            `Date`,\n"
                + "            `width`,\n"
                + "            `height`,\n"
                + "            count(`likedImages`.`imageID`) as `likes`\n"
                + "    from\n"
                + "        `image`\n"
                + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc) as `image`\n"
                + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                + "    where `pinCategory` = '" + category + "'\n"
                + "    group by `image`.`imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                + "    group by `imageID`\n"
                + "    order by `likes` desc ,`pinlikes` desc) as `categorySearch`";

        String tagsSearch = "";
        int i = 0;
        for (String tag : tags) {
            String tableName = "tags" + Integer.toString(i);
            tagsSearch += " union\n"
                    + "    \n"
                    + "        select \n"
                    + "    *\n"
                    + "from\n"
                    + "    (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            `likes`,\n"
                    + "            count(`likedpins`.`pinID`) as `pinlikes`\n"
                    + "    from\n"
                    + "        (select \n"
                    + "        `image`.`imageID`,\n"
                    + "            `ownerUsername`,\n"
                    + "            `imageFile`,\n"
                    + "            `imageTitle`,\n"
                    + "            `imageCaption`,\n"
                    + "            `isEnabled`,\n"
                    + "            `viewCount`,\n"
                    + "            `Date`,\n"
                    + "            `width`,\n"
                    + "            `height`,\n"
                    + "            count(`likedImages`.`imageID`) as `likes`\n"
                    + "    from\n"
                    + "        `image`\n"
                    + "    left join `likedimages` ON `image`.`imageID` = `likedimages`.`imageID`\n"
                    + "    group by `image`.`imageID`\n"
                    + "    order by `likes` desc) as `image`\n"
                    + "    left join `imagepins` ON `image`.`imageID` = `imagepins`.`imageID`\n"
                    + "    left join `likedpins` ON `imagepins`.`pinID` = `likedpins`.`pinID`\n"
                    + "    left join `pintag` on `pintag`.`pinID` = `imagepins`.`pinID`\n"
                    + "    where `pintag`.`pinTag` = '" + tag.trim() + "'\n"
                    + "    group by `image`.`imageID`, `pintag`.`pinID`, `pintag`.`pinTag`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `image`\n"
                    + "    left join `followers` ON `image`.`ownerUsername` = `followers`.`username`\n"
                    + "    group by `imageID`\n"
                    + "    order by `likes` desc ,`pinlikes` desc) as `" + tableName + "`";
            i++;
        }

        String startSearch = "select * from( ";
        String endSearch = 
                ") as `relatedSearch`\n"
                + " where isEnabled = 1\n"
                + " group by imageID\n"
                + " order by likes desc, pinlikes desc";

        searchString = startSearch + categorySearch + tagsSearch + endSearch;
    }

    public String getSearchString() {
//        StringSelection selection = new StringSelection(searchString);
//        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
//        clipboard.setContents(selection, selection);
        return (searchString);
    }

    public String getSearchUsername() {
        return searchUsername;
    }

    public void setSearchUsername(String searchUsername) {
        this.searchUsername = searchUsername;
    }

    public String getSearchTitle() {
        return searchTitle;
    }

    public void setSearchTitle(String searchTitle) {
        this.searchTitle = searchTitle;
    }

    public String getSearchTag() {
        return searchTag;
    }

    public void setSearchTag(String searchTag) {
        this.searchTag = searchTag;
    }

    public String getSearchCategory() {
        return searchCategory;
    }

    public void setSearchCategory(String searchCategory) {
        this.searchCategory = searchCategory;
    }

    public String getSearchPinInfo() {
        return searchPinInfo;
    }

    public void setSearchPinInfo(String searchPinInfo) {
        this.searchPinInfo = searchPinInfo;
    }

    public String getLeader() {
        return leader;
    }

    public void setLeader(String leader) {
        this.leader = leader;
    }

    public String getFollower() {
        return follower;
    }

    public void setFollower(String follower) {
        this.follower = follower;
    }
}
